package cn.xz.tipsum.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.WindowManager
import androidx.databinding.DataBindingUtil
import cn.xz.tipsum.R
import cn.xz.tipsum.bean.*
import cn.xz.tipsum.databinding.ActivityIndexBinding

class IndexActivity : AppCompatActivity() {

    private lateinit var mDataBind: ActivityIndexBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
        mDataBind = DataBindingUtil.setContentView(this, R.layout.activity_index)
        initData()
        initEvent()
    }

    private fun initData(){
        val mIntent = intent.getIntExtra(JUMP_TYPE,0)
        val mS = mErrorList[mIntent]
        mDataBind.tvTitle.text = mS.content
        if (mS.pic != null){
            mDataBind.ivPic.setImageResource(mS.pic!!)
        }
    }

    private fun initEvent(){
        mDataBind.apply {
            tvBack.setOnClickListener {
                finish()
            }
        }

    }

}